﻿namespace Framework.Serializer
{
    class JsonSerializer : StringSerializeBase
    {

        /// <summary>
        /// 序列化
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override string Serialize(object obj)
        {
            return ServiceStack.Text.JsonSerializer.SerializeToString(obj);           
        }

        /// <summary>
        /// 反序列化
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="source"></param>
        /// <returns></returns>
        public override T DeSerialize<T>(string source)
        {
            return ServiceStack.Text.JsonSerializer.DeserializeFromString<T>(source);
        }
    }
}
